Skip to content

fix: propagate file body subscriber I/O failures - #14

Closed
Wfontesd wants to merge 1 commit into
lqhuang:mainfrom
Wfontesd:fix/file-subscriber-io-failures
Closed

fix: propagate file body subscriber I/O failures#14
Wfontesd wants to merge 1 commit into
lqhuang:mainfrom
Wfontesd:fix/file-subscriber-io-failures

Conversation

@Wfontesd

@Wfontesd Wfontesd commented Sep 8, 2026

Copy link
Copy Markdown

When BodySubscribers.ofFile cannot open the destination, the body future fails but the upstream subscription remains active. If opening succeeds and a later write fails, the exception escapes onNext instead of reaching the body future.

This change cancels the subscription in both cases and sends the exception through the existing error handler, which closes the file channel and completes the body future exceptionally. Successful writes keep the same behavior.

The regression tests cover a missing parent directory and a write to Linux /dev/full, which reliably reports that the device has no space. A third test checks successful output across multiple buffers, including an empty buffer.

Validation:

  • Before the fix, Native passes the successful-output test and fails both error cases.
  • After the fix, all 160 Native tests in the subscriber, handler, and new regression suites pass.
  • All three new tests pass against JDK 25.0.2.
  • git diff --cached --check passes.

The /dev/full case runs only where that device exists. Validation was performed on Linux with Scala Native 0.5.12; no Windows or macOS Native run is claimed.

Fixed with the help of AI.

Would you consider US$35 via PayPal for accepting this focused fix? This replaces my earlier US$100 proposal in requests-scala#156. It is a proposed price, not an agreed award. Payment details can be shared privately.

Cancel the upstream subscription when opening the destination fails.
Catch write failures and use the existing error handler to close the
channel and complete the response body exceptionally.

Add regression tests for a missing parent directory and a failed write,
plus a successful multi-buffer output case. All three pass on JDK 25;
the two error cases fail on Native before the fix. The updated Native
subscriber and handler suites pass all 160 tests.
@lqhuang

lqhuang commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Close since it seems agent spam. Reopen only if you're not a bot.

@lqhuang lqhuang closed this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants